5e2a53
@@ -276,6 +276,15 @@
public static void removeUnionOperators(GenTezProcContext context, BaseWork work
               rsToSemiJoinBranchInfo.put(rs, newSJInfo);
             }
           }
+          // This TableScanOperator could also be part of other events in eventOperatorSet.
+          for(AppMasterEventOperator event: context.eventOperatorSet) {
+            if(event.getConf() instanceof DynamicPruningEventDesc) {
+              TableScanOperator ts = ((DynamicPruningEventDesc) event.getConf()).getTableScan();
+              if(ts.equals(orig)){
+                ((DynamicPruningEventDesc) event.getConf()).setTableScan((TableScanOperator) newRoot);
+              }
+            }
+          }
         }
         context.rootToWorkMap.remove(orig);
         context.rootToWorkMap.put(newRoot, work);
